#!/bin/sh 
#
# ---------------------------------------------------------------------
#                    LAN Distributed Platform - LANDP
#
#               5724-B16 (C) Copyright IBM Corp 1987, 2002
#      All Rights Reserved - Licensed Materials - Property of IBM
# ---------------------------------------------------------------------
#
# *** ID=EDITSPC  VL=A6000 HD16098K  ***

  # translate parameters to upper case
  p1=`echo $1 | tr [:lower:] [:upper:]`
  p2=`echo $2 | tr [:lower:] [:upper:]`
  p3=`echo $3 | tr [:lower:] [:upper:]`

  if [ "$p1" = "" -o "$p1" = "?" ]
  then clear
       echo " The EDITSPC procedure is used to edit:"
       echo ""
       echo "  - COMMON.SPC file (in EHCCUS directory),"
       echo "  - MODELS.SPC file (in EHCCUS directory), or"
       echo "  - LANCONF.SPC file (in a subdirectory under EHCCUS or"
       echo "                      any other at the same level)."
       echo ""
       echo " To edit COMMON.SPC the command is:   EDITSPC COMMON"
       echo " To edit MODELS.SPC the command is:   EDITSPC MODELS"
       echo ""
       echo " To edit LANCONF.SPC:"
       echo "   - If residing under EHCCUS/xxxxxxx, the command is:"
       echo ""
       echo "        EDITSPC xxxxxxxx LAN"
       echo ""
       echo "   - If residing under xxxxxxxx/yyyyyyy, the command is:"
       echo ""
       echo "        EDITSPC xxxxxxxx yyyyyyyy LAN"
       echo ""

  elif [ "$p3" != "" ]
  then if [ "$p3" != "LAN" ]
       then echo " Invalid EDITSPC parameter 3 (It must be 'LAN')"
            exit
       fi

       if [ ! -d "../$p1" ]
       then echo " Sub-directory '$p1' not found."
            echo " Do you want to create it (Y/N) ?"
            read reply
            if [ "$reply" != "Y" -a "$reply" != "y" ]
            then exit
            fi
            mkdir "../$p1"
       fi

       if [ ! -d "../$p1/$p2" ]
       then echo " Sub-directory '$p1/$p2' not found."
            echo " Do you want to create it (Y/N) ?"
            read reply
            if [ "$reply" != "Y" -a "$reply" != "y" ]
            then exit
            fi
            mkdir "../$p1/$p2"
       fi

       vi "../$p1/$p2/LANCONF.SPC"

  elif [ "$p2" != "" ]
  then if [ "$p2" != "LAN" ]
       then echo " Invalid EDITSPC parameter 2 (It must be 'LAN')"
            exit
       fi

       if [ ! -d "$p1" ]
       then echo " Sub-directory '$p1' not found."
            echo " Do you want to create it (Y/N) ?"
            read reply
            if [ "$reply" != "Y" -a "$reply" != "y" ]
            then exit
            fi
            mkdir "$p1"
       fi

       vi "$p1/LANCONF.SPC"

  elif  [ "$p1" != "COMMON" -a "$p1" != "MODELS" ]
  then echo " Invalid EDITSPC parameter 1 (It must be 'COMMON' or 'MODELS')"
  else vi "$p1.SPC"
  fi

  exit



